<?php
require_once __DIR__ . '/vendor/autoload.php';

use PhpAmqpLib\Connection\AMQPStreamConnection;

$connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest', '/');
$channel = $connection->channel();

$channel->queue_declare('work');

$callback = function ($msg) {
    echo "ing...\n";
    sleep(10);
    echo "done...'\n";
};

$channel->basic_qos(null, 1, null);
$channel->basic_consume('work', '', false, true, false, false, $callback);
echo "Received Success!\n";

while (count($channel->callbacks)) {
    $channel->wait();
}
